package dao

import (
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
	"time"
)

// Contract 字典表
type Contract struct {
	Id        int64     `json:"id" gorm:"column:id;comment:自增id"`
	HomeTitle string    `json:"home_title" gorm:"column:home_title;comment:首页标题"`
	Tip       string    `json:"tip" gorm:"column:tip;comment:场地温馨提示"`
	Address   string    `json:"address" gorm:"column:address;comment:地址"`
	Phone     string    `json:"phone" gorm:"column:phone;comment:联系方式"`
	Mark      string    `json:"mark" gorm:"column:mark;comment:预约须知"`
	Status    uint8     `json:"status" gorm:"column:status;comment:状态"`
	IsDelete  uint8     `json:"is_delete" gorm:"column:is_delete;comment:1已删除"`
	UpdatedAt time.Time `json:"update_at" gorm:"column:update_at;comment:更新时间"`
	CreatedAt time.Time `json:"create_at" gorm:"column:create_at;comment:创建时间"`
}

func (f *Contract) TableName() string {
	return "contract"
}

// InitData 初始化dic_data表
func (f *Contract) InitData(tx *gorm.DB) error {
	return tx.AutoMigrate(f)
}

// Save 保存
func (f *Contract) Save(c *gin.Context, tx *gorm.DB) error {
	if err := tx.WithContext(c).Save(f).Error; err != nil {
		return err
	}
	return nil
}
